
// 发送ajax请求
$.ajax({
    url: 'http://localhost:8888/api/swipers',
    type: 'get',
    success: function (res) {
        console.log(res);
        let str = '';
        res.data.forEach(item => {
            str += `
             <li class="img-effect">
              <a href="javascript:;">
                <img src="http://localhost:8888/uploads/${item.swiperimg}" alt="">
              </a>
            </li>
         `;
        })
        $('#lunbotu').html(str);

        layui.use('carousel', function () {
            // 轮播模块
            let carousel = layui.carousel;

            // 轮播交互
            carousel.render({
                elem: '#kr_carousel',
                width: 720,
                height: 300,
                interval: 3000
            })
        })
    }
})
// 加载友情链接
load();
//  加载友情链接
function load() {
    $.ajax({
        url: 'http://localhost:8888/api/links',
        success: function (res) {
            let arr = ['<dt>合作伙伴</dt>'];
            res.data.forEach(item => {
                arr.push(`
                  <dd>
                  <a href="javascript:;">
                    <img src="http://localhost:8888/uploads/${item.linkicon}" alt="${item.linkname}">
                  </a>
                </dd>
                 `);
            })
            $('#kr-collaborator').html(arr.join(''));
        }
    })
}
load();